using UnityEngine;
// [Assembly-CSharp.dll].BeeController
public class BeeController : MonoBehaviour
{
    
    #region BeeController.STATE
    // [Assembly-CSharp.dll].BeeController.STATE
    public enum STATE
    {
        // Fields
        WAIT = 0
        ,MOVE = 1
        ,ATTACK = 2
        
    
    }
    
    #endregion
    
    // Fields
    protected UnityEngine.Rigidbody2D mRigidbody;
    protected UnityEngine.Transform target;
    public UnityEngine.GameObject deathVfx;
    public UnityEngine.GameObject redHit;
    public BeeController.STATE currentState;
    public float charingTime;
    private float timer;
    public UnityEngine.AudioSource beeSound;
    
    // Methods
    private void Awake()
    {
        this.mRigidbody = this.GetComponent<System.Object>();
        mem[1152921504930430456] = 0;
    }
    private void Start()
    {
        this.SetActiveSelectedBee();
        this.target = mem[536886749] + 24 + 32.Item[UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  mem[536886749] + 24 + 32 + 24)].GetChild(index:  UnityEngine.PlayerPrefs.GetInt(key:  -1610599417));
        mem[1152921504930430464] = 0;
        this.beeSound.volume = ((mem[536882947] + 176) == 0) ? 0f : 1f;
    }
    private void Update()
    {
    
    }
    private void FixedUpdate()
    {
        float val_32;
        UnityEngine.Rigidbody2D val_33;
        float val_34;
        float val_35;
        float val_36;
        float val_37;
        float val_38;
        float val_39;
        if((mem[536895017] + 12) != 0)
        {
                UnityEngine.Object.Destroy(obj:  this.gameObject, t:  1f);
        }
        
        if(this.target == 0)
        {
                return;
        }
        
        UnityEngine.Vector3 val_4 = this.transform.position;
        val_32 = val_4.x;
        UnityEngine.Vector3 val_6 = this.target.transform.position;
        this.transform.GetChild(index:  0).GetComponent<System.Object>().flipX = (val_32 >= 0) ? 1 : 0;
        if(this.currentState == 2)
        {
            goto label_11;
        }
        
        if(this.currentState != 1)
        {
                return;
        }
        
        val_33 = this.mRigidbody;
        UnityEngine.Vector3 val_11 = this.target.position;
        val_34 = val_11.z;
        UnityEngine.Vector3 val_13 = this.transform.position;
        float val_28 = val_13.x;
        float val_29 = val_13.z;
        float val_30 = (float)UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  1);
        val_28 = val_28 + ((float)UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  1));
        val_35 = val_13.y + val_30;
        val_29 = val_29 + 0f;
        val_28 = val_11.x - val_28;
        val_36 = val_11.y - val_35;
        float val_17 = val_28 * val_28;
        val_30 = val_36 * val_36;
        val_17 = val_17 + val_30;
        float val_18 = (val_34 - val_29) * (val_34 - val_29);
        val_17 = val_18 + val_17;
        if(val_18 <= (1E-05f))
        {
            goto label_17;
        }
        
        val_37 = val_28 / val_18;
        val_38 = val_36 / val_18;
        if(val_33 != null)
        {
            goto label_18;
        }
        
        label_11:
        val_32 = this.timer;
        float val_19 = UnityEngine.Time.deltaTime;
        val_19 = val_32 + val_19;
        this.timer = val_19;
        if(val_19 >= this.charingTime)
        {
            goto label_20;
        }
        
        return;
        label_17:
        val_37 = mem[mem[536895737]];
        val_37 = mem[536895737];
        val_38 = mem[mem[536895737] + 4];
        val_38 = mem[536895737] + 4;
        label_18:
        val_39 = 10f;
        goto label_23;
        label_20:
        val_33 = this.mRigidbody;
        UnityEngine.Vector3 val_20 = this.target.position;
        val_34 = val_20.z;
        UnityEngine.Vector3 val_22 = this.transform.position;
        float val_31 = val_22.x;
        float val_32 = val_22.z;
        float val_33 = (float)UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  1);
        val_31 = val_31 + ((float)UnityEngine.Random.Range(minInclusive:  0, maxExclusive:  1));
        val_35 = val_22.y + val_33;
        val_32 = val_32 + 0f;
        val_31 = val_20.x - val_31;
        val_36 = val_20.y - val_35;
        float val_26 = val_31 * val_31;
        val_33 = val_36 * val_36;
        val_26 = val_26 + val_33;
        float val_27 = (val_34 - val_32) * (val_34 - val_32);
        val_26 = val_27 + val_26;
        if(val_27 <= (1E-05f))
        {
            goto label_28;
        }
        
        val_37 = val_31 / val_27;
        val_38 = val_36 / val_27;
        if(val_33 != null)
        {
            goto label_29;
        }
        
        label_28:
        val_37 = mem[mem[536895737]];
        val_37 = mem[536895737];
        val_38 = mem[mem[536895737] + 4];
        val_38 = mem[536895737] + 4;
        label_29:
        val_39 = 15f;
        label_23:
        val_37 = val_37 * val_39;
        val_38 = val_38 * val_39;
        val_33.AddForce(force:  new UnityEngine.Vector2());
    }
    private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
    {
        if((System.String.op_Equality(a:  collision.gameObject.tag, b:  -1610605719)) != false)
        {
                this.currentState = 2;
            this.timer = 0f;
        }
        
        if((System.String.op_Equality(a:  collision.gameObject.tag, b:  -1610609439)) != false)
        {
                this.currentState = 2;
            this.timer = 0f;
        }
        
        if((System.String.op_Equality(a:  collision.gameObject.tag, b:  -1610608115)) != false)
        {
                this.currentState = 2;
            this.timer = 0f;
            collision.gameObject.GetComponent<System.Object>().Hurt();
            UnityEngine.Vector3 val_15 = this.transform.position;
            UnityEngine.Object.Instantiate<System.Object>(original:  this.redHit).transform.position = new UnityEngine.Vector3() {x = val_15.x, y = val_15.y, z = val_15.z};
            mem[536882947].MediumImpect();
        }
        
        if((System.String.op_Equality(a:  collision.gameObject.tag, b:  -1610605751)) != true)
        {
                if((System.String.op_Equality(a:  collision.gameObject.tag, b:  -1610601399)) == false)
        {
                return;
        }
        
        }
        
        UnityEngine.Vector3 val_23 = this.transform.position;
        Unknown val_24 = UnityEngine.Object.Instantiate<System.Object>(original:  this.deathVfx, position:  new UnityEngine.Vector3() {x = val_23.x, y = val_23.y, z = val_23.z}, rotation:  new UnityEngine.Quaternion() {x = mem[536891277], y = mem[536891277] + 4, z = mem[536891277] + 8, w = mem[536891277] + 8 + 4});
        UnityEngine.Object.Destroy(obj:  this.gameObject);
    }
    private void StartToAttack()
    {
        this.currentState = 2;
        this.timer = 0f;
    }
    private void SetActiveSelectedBee()
    {
        var val_11 = 0;
        label_6:
        if(val_11 >= this.transform.childCount)
        {
            goto label_2;
        }
        
        this.transform.GetChild(index:  0).gameObject.SetActive(value:  false);
        val_11 = val_11 + 1;
        if(this.transform != null)
        {
            goto label_6;
        }
        
        label_2:
        this.transform.GetChild(index:  UnityEngine.PlayerPrefs.GetInt(key:  -1610599419)).gameObject.SetActive(value:  true);
    }
    public BeeController()
    {
    
    }

}
